package mediatheque.controller;

import mediatheque.model.AudioModel;
import mediatheque.model.MediathequeModel;
import mediatheque.view.AudioView;

public class AudioController extends DocumentController {


	public AudioController(MediathequeModel model, final AudioView view) {
		this(model, view, null);		
	}
	
	public AudioController(MediathequeModel model, final AudioView view, AudioModel audio) {
		super(model, view, audio);
	}

	protected boolean verifierChamps() {
		return (super.verifierChamps() && !((AudioView) view).getValeurDuree().isEmpty());
	}

	protected void enregistrer() {
		if(document == null){
			document = new AudioModel();
			model.ajouterDocument(document.getIdentifiant(), (AudioModel)document);
		}

		((AudioModel) document).setDuree(((AudioView) view).getValeurDuree());

		super.enregistrer();
	}
	
	
}
